package com.yonyou.hxjy.enums;

public enum SettleMode {
    CASH("1", "现金"),
    CHECK("2", "支票"),
    BANKDRAFT("3", "银行汇票"),
    CASHIERS("4", "银行本票"),
    CARD("5", "信用卡"),
    SCANCODE("699", "扫码"),
    TRANSFERACCOUNT("997", "转账"),
    WECHAT("998", "微信"),
    ALIPAY("999", "支付宝");

    private String code;
    private String name;

    SettleMode(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getname() {
        return name;
    }

    public void setname(String name) {
        this.name = name;
    }

    /**
     * 根据服务code获取结算名称
     *
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        SettleMode[] settleModes = values();
        for (SettleMode homeService : settleModes) {
            if (homeService.getCode() == code) {
                return homeService.getname();
            }
        }
        return null;
    }

    /**
     * 根据结算名称获取服务code
     *
     * @param name
     * @return
     */
    public static String getCodeByName(String name) {
        SettleMode[] settleModes = values();
        for (SettleMode homeService : settleModes) {
            if (homeService.getname().equals(name) ) {
                return homeService.getCode();
            }
        }
        return null;
    }
}
